import vuePlugin from 'eslint-plugin-vue';
import typescriptEslintParser from '@typescript-eslint/parser';
import typescriptEslintPlugin from '@typescript-eslint/eslint-plugin';
import vueEslintParser from 'vue-eslint-parser';

export default [
    {
        files: ['**/*.vue'],
        languageOptions: {
            parser: vueEslintParser,
            parserOptions: {
                parser: typescriptEslintParser,
                ecmaVersion: 'latest',
                sourceType: 'module'
            },
            globals: {
                // 模拟 browser 环境的全局变量
                window: 'readonly',
                document: 'readonly',
                // 模拟 es2021 环境的全局变量（根据需要添加更多）
                Promise: 'readonly',
                BigInt: 'readonly'
            }
        },
        plugins: {
            vue: vuePlugin
        },
        rules: {
            ...vuePlugin.configs['vue3-essential'].rules
        }
    },
    {
        files: ['**/*.ts'],
        languageOptions: {
            parser: typescriptEslintParser,
            parserOptions: {
                ecmaVersion: 'latest',
                sourceType: 'module'
            },
            globals: {
                // 模拟 es2021 环境的全局变量（根据需要添加更多）
                Promise: 'readonly',
                BigInt: 'readonly'
            }
        },
        plugins: {
            '@typescript-eslint': typescriptEslintPlugin
        },
        rules: {
            ...typescriptEslintPlugin.configs.recommended.rules
        }
    },
    {
        rules: {
            // 这里可以自定义规则
        }
    }
];